package config

import (
	"flag"
	"fmt"
	"github.com/jinzhu/configor"
	"time"
)

var Config = struct {
	APPName         string `default:"app name"`
	Port            string `default:"3344"`
	Mode            string `default:"debug"`
	Domain          string `default:"localhost"`
	HTMLFilePath    string `default:"public/index.html"`
	ExceptAuthRoute exceptAuthRoute
	Sign            sign
	Redis           redis
	Skittle         skittle
}{}

func init() {
	configFile := flag.String("C", "config.yml", "configFileName")
	flag.Parse()
	//fmt.Println("backup_dir:", *configFile)
	configFileName := *configFile
	_ = configor.New(&configor.Config{
		AutoReload:         true,
		AutoReloadInterval: time.Second,
		AutoReloadCallback: func(config interface{}) {
			//config变化后触发
			fmt.Printf("%v changed \r\n", config)
		},
	}).Load(&Config, configFileName)
}
